//
//  HLLiveGiftCollectionViewCell.m
//  YueYue
//
//  Created by hulu001 on 2024/3/14.
//

#import "HLLiveGiftCollectionViewCell.h"

@interface HLLiveGiftCollectionViewCell ()

@property (nonatomic, strong) UIView *backView;
@property (nonatomic, strong) UIImageView *giftImageView;
@property (nonatomic, strong) UILabel *giftNameLabel;
@property (nonatomic, strong) UILabel *giftPriceLabel;

@end

@implementation HLLiveGiftCollectionViewCell


-(instancetype)initWithFrame:(CGRect)frame{
    
    if ([super initWithFrame:frame]) {
        self.backgroundColor= UIColorBlack;
        [self setupView];
    }
    return self;
    
}

- (void)setupView
{
    self.backView = [[UIView alloc] init];
    _backView.layer.masksToBounds = YES;
    _backView.layer.cornerRadius = 9;
    _backView.layer.borderColor = UIColorBlack.CGColor;
    _backView.layer.borderWidth = 1;
    [self.contentView addSubview:_backView];
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    
    self.giftImageView = [UIImageView.alloc init];
    _giftImageView.image = UIImageMake(@"mine_chong");
    _giftImageView.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:_giftImageView];
    [_giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.top.mas_equalTo(6);
        make.right.mas_equalTo(-12);
        make.height.mas_equalTo(48);
    }];
    
    self.giftNameLabel = [[UILabel alloc] init];
    _giftNameLabel.textColor = UIColorWhite;
    _giftNameLabel.font = UIFontMediumMake(10);
    _giftNameLabel.text = @"加载中";
    _giftNameLabel.textAlignment = NSTextAlignmentCenter;
    _giftNameLabel.numberOfLines = 0;
    [self.contentView addSubview:_giftNameLabel];
    [_giftNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.equalTo(_giftImageView.mas_bottom).offset(6);
    }];
    
    self.giftPriceLabel = [[UILabel alloc] init];
    _giftPriceLabel.textColor = HLTextColor3;
    _giftPriceLabel.font = UIFontMake(8);
    _giftPriceLabel.text = @"20金币";
    _giftPriceLabel.textAlignment = NSTextAlignmentCenter;
    _giftPriceLabel.numberOfLines = 0;
    [self.contentView addSubview:_giftPriceLabel];
    [_giftPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.equalTo(_giftNameLabel.mas_bottom).offset(6);
    }];
    
}


-(void)setModel:(HLLiveGiftModel *)model
{
    
    
    [self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.giftUrl]];
    self.giftNameLabel.text = model.giftName;
    self.giftPriceLabel.text = [NSString stringWithFormat:@"%@%@",model.giftPrice, @"金币"];
    
    if (model.isChange) {
        self.backView.layer.borderColor = HLMainColor.CGColor;
    }else{
        self.backView.layer.borderColor = UIColorBlack.CGColor;
    }
  
    
}

- (void)setCellHidden:(BOOL)isHidden
{
    self.giftImageView.hidden = isHidden;
    self.giftNameLabel.hidden = isHidden;
    self.giftPriceLabel.hidden = isHidden;
    self.backView.hidden = isHidden;
}


@end
